/**
 Copyright will be fixed soon.
 Author: Hiroshi Ota.
 $Date: $
 $Revision: $
*/

#ifdef _BRICKOS_
#include "c++/Motor.h"
#endif

#ifndef _BRICKOS_

#ifndef _PW_MOTOR_H_
#define _PW_MOTOR_H_

#include "ISimulatorControl.h"

// from <dmotor.h>
typedef enum {
        off = 0,
        fwd = 1,
        rev = 2,
        brake = 3
} MotorDirection;

class Motor
{
public:
        enum Port {
                A=1,
                B,
                C
        };

        enum Limits {
                min=0,
                max=255
        };

        Motor(const Port port, ISimulatorControl* sc=0, char* name=0);
        ~Motor(void) { off(); }

        const void speed(const unsigned char speed) const;
        const void direction(const MotorDirection dir) const;
        const void forward() const;
        const void forward(const unsigned char s) const { forward(); speed(s); }
        const void reverse() const { direction(rev); }
        const void reverse(const unsigned char s) const { reverse(); speed(s); }
        const void brake() const;
        const void brake(int duration) const;
        const void off() const;

private:
	ISimulatorControl* simCon;
	Port myPort;

};


#define  MIN_SPEED      0       //!< minimum motor speed
#define  MAX_SPEED      255     //!< maximum motor speed

#endif // _PW_MOTOR_H_

#endif // _BRICKOS_

